home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / tlx_sq21.zip / OPUS.SLT < prev    next >
Text File  |  1992-03-20  |  10KB  |  319 lines

  1. //-----------------------------------------------------------
  2. // OPUS.SL? Automatic logging into an OPUS system.
  3. //
  4. // Please look at the comments through the whole file, and modify to
  5. // suit your needs, BEFORE you use it. Then recompile with CS OPUS.
  6. //-----------------------------------------------------------
  7.  
  8. // If you have suggestions for improving this script, please suggest
  9. // improvements to me via old-fashioned snail-mail to:
  10.  
  11. // Author:  Inge Vabekk
  12. //          Hamangskogen 108
  13. //          N-1300 SANDVIKA
  14. //          NORWAY
  15. //          tel. (472) 546 396
  16.  
  17. str thisBBStype[] = "OPUS"   // This BBS type.      
  18.    ,line      [80]           // General input line.
  19.    ,filelist  [12]           // Name of file list for this BBS.
  20.    ,myprot     [2]           // Chosen protocol.
  21.    ,hisprot    [2]           // OPUS's translation.
  22.    ,User      [32]           // Your own name.      
  23.  
  24.                              // For the Global storage:
  25.    ,global   []="GLOBAL"     // Global script.
  26.    ,username []="NAME"       // User name
  27.    ,PutLine  []="PUTLINE"    // PutLine script.
  28.    ,bbstype  []="BTYPE"      // BBS type.
  29.    ,cprot    []="CPROT"      // Current protocol.
  30.    ,hprot    []="HPROT"      // OPUS's interpretation of protocol
  31.    ,prompt   []="PROMPT"     // Current prompt (global name)
  32.    ,mscript  []="MDOOR"      // Name of mail door.
  33.    ,password []="PASSWORD"   // Script to send password.
  34.    ,mailup   []="MAILUP"     // Name of upload mail script.
  35.    ,Update   []="UPDATE$"    // Name of update program.
  36.    ,command[10]="Select:"    // Current prompt (value)
  37.    ;
  38.  
  39. int tol = 300                // No activity for 30 seconds
  40.    ,t1, t2, t3, t4, t5       // makes script time out. 
  41.    ,stat, tmark
  42.    ,messages                 // Messages to fetch?
  43.    ,Enter = 13
  44.    ;
  45.  
  46. //-----------------------------------------------------------   
  47. // Script starts here.
  48. //-----------------------------------------------------------   
  49.  
  50. main(int ppass)
  51. {
  52. int c, i, OK
  53.    ,langno                             // Language number
  54.    ;
  55.  
  56.   entry();                             // Updates colors & status bar. 
  57.  
  58. // Only if online.
  59.  
  60.   if (!carrier())  
  61.   { failtone();
  62.     status_wind ("T²: THIS SCRIPT ONLY WORKS IF YOU'RE ONLINE!",20);
  63.     return (-1);
  64.   }
  65.  
  66.   read (bbstype,line);                 // Get current BBS type.
  67.   if (line != thisBBStype)  
  68.   { wrongBBS();                        // Doesn't match script!
  69.     return (-1);
  70.   }
  71.  
  72. // Name and password.
  73.  
  74.   t1 = track ("FIRST name:",0);        // Wait for first name prompt.
  75.   t2 = 0;
  76.   t3 = track ("[Y,n]?", 0);            // Name OK?
  77.   t4 = track ("Language", 0);          // would you like to use?
  78.   t5 = track ("Password:", 0);         // Password OK?
  79.   tmark = timer_start (tol);           // Give me a minute.
  80.  
  81.   OK = 0;
  82.   do
  83.   { stat=trig();                       // Check prompts.
  84.  
  85.     if (stat == t1)                    // User name?
  86.     { read (username,User);            // Get the user name.
  87.       call (PutLine,User,Enter);       // Send it.
  88.       t2 = track (User, 0);            // Check echo.
  89.     }
  90.     else if (stat == t2)               // User name again?
  91.     { OK = 1;
  92.       track_free (t2);                 // Got it!
  93.       t2 = 0;
  94.     }
  95.     else if (stat == t3)               // User name correct?
  96.     { if (OK)
  97.         call (PutLine,"Y",Enter);
  98.       else
  99.         call (PutLine,"N",Enter);
  100.     }
  101.     else if (stat == t4)                     // Language?
  102.     { waitfor ("Select:",2);
  103.       langno = -1;
  104.       i = gety();                            // Get position.
  105.       for (c=0; c<=i; ++c)                   // Get screen line.
  106.       { vgetchrs(0,c,line,0,80);
  107.         if (strposi (line,"English",0) > 0)  // Language no.?
  108.         { langno =subchr(line,firstp(line)); // Get language no. to use.
  109.           break;
  110.         }
  111.       }
  112.       if (langno > 0) cputc (langno);  // Set language.
  113.       cputc (Enter);
  114.     }
  115.     else if (stat == t5)               // Password?
  116.     { ++OK;  
  117.       call (password);
  118.     }
  119.   } while (OK < 2);                    // Until name+password are OK.
  120.   release();                           // Release tracks.
  121.  
  122.   if (OK ==1) call (password);         // Password not recognised.
  123.  
  124. // Start tracking texts.
  125.  
  126.   command = "Select:";
  127.   write (prompt,command);
  128.  
  129.   t1 = track ("not recogni", 0);       // Not registered!
  130.   t2 = track ("to continue", 0);       // ENTER to continue
  131.   t3 = track (command, 0);             // Next command.
  132.  
  133.   tmark = timer_start (tol);           // Give me a minute.
  134.  
  135.   cputs ("^M");                        // Send Enter to proceed.
  136.  
  137.   while ((stat=trig()) > 0)            // Check prompts.
  138.   { if (stat == t1)                    // Not registered?
  139.     { release();
  140.       call ("OPUSREG");                // So do it.
  141.       break;
  142.     }
  143.     else if (stat == t2)
  144.       cputc (Enter);                   // ENTER to continue
  145.     else
  146.       break;
  147.   }
  148.   release();
  149.  
  150. // Check protocol.
  151.           
  152.   if (read (cprot,myprot)<0)           // Get protocol.
  153.     myprot = "Z";
  154.   if (myprot=="Y")                     // This is kind of
  155.     hisprot = "YB";                    // a translate table
  156.   else if (myprot=="E")                // for the protocol.
  157.     hisprot = "YG";
  158.   else if (myprot=="1")
  159.     hisprot = "X";
  160.   else if (myprot=="D")
  161.     hisprot = "Z";
  162.   else
  163.     hisprot = myprot;
  164.   write (Hprot,hisprot);               // Save it for later.
  165.  
  166.   waitfor (command,100);        //!!!!!!!!!!!!!!!!!!!!!!!!
  167.   write (mscript,mailup);              // Next script.
  168.   return (0);                          // Return.
  169. }
  170.  
  171. //-----------------------------------------------------------
  172. // Wrong BBS type.
  173. //-----------------------------------------------------------
  174.  
  175. wrongBBS()
  176. {
  177.   failtone();                          // Alarm.    
  178.   line = "This script is for ";        // Catenate strings.
  179.   strcat (line,thisBBStype);
  180.   strcat (line," only!");
  181.   status_wind (line,20);               // Display message for 2 sec.
  182. }
  183.  
  184. //-----------------------------------------------------------
  185. // Change the language to English.
  186. //-----------------------------------------------------------
  187.  
  188. english() 
  189. {
  190.   call (PutLine, "U SPR", Enter);        // Change language.
  191.   waitfor ("engelsk",1);
  192.   cputs ("^M");
  193.   messages = 10;                         // Didn't trig on messages;
  194. }                                        // assume there are some.
  195.  
  196. //-----------------------------------------------------------
  197. // Flush incoming text from BBS.
  198. //-----------------------------------------------------------
  199.  
  200. flush()
  201. {
  202.   do
  203.   { terminal();                          // Process all echo
  204.     delay(2);                            // from the BBS.
  205.   } while (cinp_cnt() > 0);
  206. }
  207.  
  208. //-----------------------------------------------------------
  209. // Play fail tone.
  210. //-----------------------------------------------------------
  211.  
  212. failtone()
  213. {
  214.   int n;
  215.   for (n=140; n > 10; n = 100*n/120) 
  216.   { tone(n*10,12);                       // Fail tone!!
  217.     terminal();                          // Process text.
  218.   }
  219. }
  220.  
  221. //-----------------------------------------------------------
  222. // Routine to update colors and status bar.
  223. //-----------------------------------------------------------
  224.  
  225. entry ()
  226. {
  227.   _back_color = 1;
  228.   _fore_color = 14;
  229.   update_term();
  230. }
  231.  
  232. //-----------------------------------------------------------
  233. // Play good tune.
  234. //-----------------------------------------------------------
  235.  
  236. goodtone()
  237. {
  238. int n;
  239.   for (n=20; n < 200; n = 144*n/100) 
  240.   { tone(n*10,6);                        // Good tone!
  241.     terminal();                          // Process text.
  242.   }
  243. }
  244.  
  245. //-----------------------------------------------------------
  246. //  Trig loop. Waits here until either one "trig string" is
  247. //  found, or we have a time-out, or carrier is lost.
  248. //-----------------------------------------------------------
  249.  
  250. trig()
  251. {
  252. int i;
  253.   do
  254.   { terminal();
  255.   }  while (!time_up (tmark)             // Loop until time-out
  256.           && carrier()